package cn.renxuan.service.weather.json;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Data;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class BaiduWeather {

    public class Location {
        private String country;

        private String province;

        private String city;

        private String name;

        private String id;

        public String getCountry() {
            return country;
        }

        public void setCountry(String country) {
            this.country = country;
        }

        public String getProvince() {
            return province;
        }

        public void setProvince(String province) {
            this.province = province;
        }

        public String getCity() {
            return city;
        }

        public void setCity(String city) {
            this.city = city;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }
    }

    public class Now {
        private String text; // 天气现象文字描述
        private int temp; // 温度(℃)
        private int feels_like; // 体感温度(℃)
        private int rh; // 相对湿度(%)
        private String wind_class; // 风力等级
        private String wind_dir; // 风向
        private double prec_1h; // 1小时降水量(mm)
        private int clouds; // 云量(%)
        private int vis; // 能见度(米)
        private int aqi; // 空气质量指数
        private int pm25; // PM2.5浓度(μg/m³)
        private int pm10; // PM10浓度(μg/m³)
        private int no2; // 二氧化氮浓度(μg/m³)
        private int so2; // 二氧化硫浓度(μg/m³)
        private int o3; // 臭氧浓度(μg/m³)
        private double co; // 一氧化碳浓度(mg/m³)
        private LocalDateTime uptime; // 数据更新时间

        // 无参构造函数
        public Now() {
        }

        // getter和setter方法
        public String getText() {
            return text;
        }

        public void setText(String text) {
            this.text = text;
        }

        public int getTemp() {
            return temp;
        }

        public void setTemp(int temp) {
            this.temp = temp;
        }

        public int getFeels_like() {
            return feels_like;
        }

        public void setFeels_like(int feels_like) {
            this.feels_like = feels_like;
        }

        public int getRh() {
            return rh;
        }

        public void setRh(int rh) {
            this.rh = rh;
        }

        public String getWind_class() {
            return wind_class;
        }

        public void setWind_class(String wind_class) {
            this.wind_class = wind_class;
        }

        public String getWind_dir() {
            return wind_dir;
        }

        public void setWind_dir(String wind_dir) {
            this.wind_dir = wind_dir;
        }

        public double getPrec_1h() {
            return prec_1h;
        }

        public void setPrec_1h(double prec_1h) {
            this.prec_1h = prec_1h;
        }

        public int getClouds() {
            return clouds;
        }

        public void setClouds(int clouds) {
            this.clouds = clouds;
        }

        public int getVis() {
            return vis;
        }

        public void setVis(int vis) {
            this.vis = vis;
        }

        public int getAqi() {
            return aqi;
        }

        public void setAqi(int aqi) {
            this.aqi = aqi;
        }

        public int getPm25() {
            return pm25;
        }

        public void setPm25(int pm25) {
            this.pm25 = pm25;
        }

        public int getPm10() {
            return pm10;
        }

        public void setPm10(int pm10) {
            this.pm10 = pm10;
        }

        public int getNo2() {
            return no2;
        }

        public void setNo2(int no2) {
            this.no2 = no2;
        }

        public int getSo2() {
            return so2;
        }

        public void setSo2(int so2) {
            this.so2 = so2;
        }

        public int getO3() {
            return o3;
        }

        public void setO3(int o3) {
            this.o3 = o3;
        }

        public double getCo() {
            return co;
        }

        public void setCo(double co) {
            this.co = co;
        }

        public LocalDateTime getUptime() {
            return uptime;
        }

        public void setUptime(String uptime) {
            // 解析格式为"yyyyMMddHHmmss"的时间字符串
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
            this.uptime = LocalDateTime.parse(uptime, formatter);
        }

        @Override
        public String toString() {
            return "WeatherData{" +
                    "text='" + text + '\'' +
                    ", temp=" + temp +
                    ", feels_like=" + feels_like +
                    ", rh=" + rh +
                    ", wind_class='" + wind_class + '\'' +
                    ", wind_dir='" + wind_dir + '\'' +
                    ", prec_1h=" + prec_1h +
                    ", clouds=" + clouds +
                    ", vis=" + vis +
                    ", aqi=" + aqi +
                    ", pm25=" + pm25 +
                    ", pm10=" + pm10 +
                    ", no2=" + no2 +
                    ", so2=" + so2 +
                    ", o3=" + o3 +
                    ", co=" + co +
                    ", uptime=" + uptime +
                    '}';
        }
    }

    private Location location; // 地理位置信息

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public Now getNow() {
        return now;
    }

    public void setNow(Now now) {
        this.now = now;
    }

    private Now now; // 实时天气数据
}
